Add pushAnimationMutations to the AnimationBackend#56401
Open
bartlomiejbloniarz wants to merge 1 commit intomainfrom
Open
Add pushAnimationMutations to the AnimationBackend#56401bartlomiejbloniarz wants to merge 1 commit intomainfrom
bartlomiejbloniarz wants to merge 1 commit intomainfrom
Conversation
|
@bartlomiejbloniarz has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100164749. |
Summary: Add `pushAnimationMutations(Callback)` to the AnimationBackend as a targeted alternative to `trigger()`. The existing `trigger()` method has two problems: 1. **Blast radius**: It calls `onAnimationFrame()` which invokes ALL registered callbacks. When one animation frontend (e.g. Animated) calls `trigger()` in response to an event, every other frontend (e.g. Reanimated) also spins up unnecessarily. 2. **Broken timestamp on iOS**: `trigger()` uses `std::chrono::steady_clock` which on iOS maps to a different kernel clock than what `CADisplayLink` uses for vsync timestamps. These clocks have different baselines and can diverge over time (e.g. after device sleep), causing animations to see time jumps. `pushAnimationMutations(Callback)` fixes both issues: - Executes only the provided callback, not all registered ones - Uses `AnimationChoreographer::now()` which delegates to `HighResTimeStamp`, providing a timestamp from the same clock as the vsync path on each platform Also refactors `onAnimationFrame` to use `unpackMutations`/`applySurfaceUpdates` helpers, avoiding intermediate vector/set merging when accumulating mutations from multiple callbacks. ## Changelog: [General][Added] - Add pushAnimationMutations to AnimationBackend for targeted event-driven animation updates Differential Revision: D100164749
7ed418e to
630d006
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Add
pushAnimationMutations(Callback)to the AnimationBackend as a targeted alternative totrigger().The existing
trigger()method has two problems:Blast radius: It calls
onAnimationFrame()which invokes ALL registered callbacks. When one animation frontend (e.g. Animated) callstrigger()in response to an event, every other frontend (e.g. Reanimated) also spins up unnecessarily.Broken timestamp on iOS:
trigger()usesstd::chrono::steady_clockwhich on iOS maps to a different kernel clock than whatCADisplayLinkuses for vsync timestamps. These clocks have different baselines and can diverge over time (e.g. after device sleep), causing animations to see time jumps.pushAnimationMutations(Callback)fixes both issues:AnimationChoreographer::now()which delegates toHighResTimeStamp, providing a timestamp from the same clock as the vsync path on each platformAlso refactors
onAnimationFrameto useunpackMutations/applySurfaceUpdateshelpers, avoiding intermediate vector/set merging when accumulating mutations from multiple callbacks.Changelog:
[General][Added] - Add pushAnimationMutations to AnimationBackend for targeted event-driven animation updates
Differential Revision: D100164749